/*
 * Teknei 2014 - All rights reserved
 */
package com.teknei.acabus.core.services.impl;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import com.teknei.acabus.PersistenceException;
import com.teknei.acabus.ServiceException;
import com.teknei.acabus.core.entities.NavigationChild;
import com.teknei.acabus.core.entities.NavigationParent;
import com.teknei.acabus.core.persistence.dao.NavigationDAO;
import com.teknei.acabus.core.services.NavigationService;

/**
 * Session Bean implementation class NavigationServiceBean
 * @author Jorge Amaro
 * @version 1.0
 * @since 1.0
 */
@Stateless
public class NavigationServiceBean implements NavigationService {

	@EJB
	private NavigationDAO daoNavigation;
	
	/* (non-Javadoc)
	 * @see com.teknei.acabus.core.services.NavigationService#findNavigationParents()
	 */
	@Override
    public List<NavigationParent> findNavigationParents() throws ServiceException{
		try{
			List<NavigationParent> list = daoNavigation.findAllNavParent();
	    	return list;
		}catch(PersistenceException e){
			throw new ServiceException("Error in findNavigationParents:"+e.getMessage(), e);
		}
    	
    }
    
	/* (non-Javadoc)
	 * @see com.teknei.acabus.core.services.NavigationService#findNavigationChilds(int)
	 */
	@Override
    public List<NavigationChild> findNavigationChilds(int idParent) throws ServiceException{
		try{
			List<NavigationChild> list = daoNavigation.findNavChildRelated(idParent);
	    	return list;
		}catch(PersistenceException e){
			throw new ServiceException("Error in findNavigationChilds:"+e.getMessage(), e);
		}
    	
    }
	
	/* (non-Javadoc)
	 * @see com.teknei.acabus.core.services.NavigationService#findNavigationChilds()
	 */
	@Override
    public List<NavigationChild> findNavigationChilds() throws ServiceException{
		try{
			List<NavigationChild> list = daoNavigation.findAllNavChild();
	    	return list;
		}catch(PersistenceException e){
			throw new ServiceException("Error in findNavigationChilds:"+e.getMessage(), e);
		}
    	
    }
	

	/**
	 * @return the daoNavigation
	 */
	public NavigationDAO getDaoNavigation() {
		return daoNavigation;
	}

	/**
	 * @param daoNavigation the daoNavigation to set
	 */
	public void setDaoNavigation(NavigationDAO daoNavigation) {
		this.daoNavigation = daoNavigation;
	}

}
